#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN = 1e5+7;
LL cnt[MAXN];

int main() {
    LL n;
    scanf("%lld", &n);
    for (LL i=0, t; i<n; ++i) {
        scanf("%lld", &t);
        ++cnt[t];
    }
    LL res = 0;
    for (LL i=1; i<=448; ++i) {
        LL pp = i*i;
        for (LL j=0; j<MAXN; ++j) {
            if (pp-j >= MAXN || pp-j < 0) continue;
            if (pp-j != j)res += cnt[pp-j] * cnt[j];
            else res += cnt[j] * (cnt[j] - 1);
        }
    }
    printf("%lld\n", res/2);
    return 0;
}
